package by.grsu.coctails;

import android.app.Application;
import by.grsu.coctails.common.handler.ImageContentHandler;
import by.grsu.coctails.db.DBManager;
import by.grsu.coctails.utils.ContextHolder;

import com.google.android.imageloader.ImageLoader;

public class CoctailApplication extends Application {

	private DBManager dbManager;

	private ImageLoader imageLoader;

	@Override
	public void onCreate() {
		super.onCreate();
		dbManager = new DBManager(getApplicationContext());
		imageLoader = new ImageLoader(new ImageContentHandler(getApplicationContext()), null);
		new ContextHolder(getApplicationContext());
	}

	@Override
	public Object getSystemService(String name) {
		if (name.equals(DBManager.DB_MANAGER)) {
			return dbManager;
		}
		if (name.equals(ImageLoader.IMAGE_LOADER_SERVICE)) {
			return imageLoader;
		}
		return super.getSystemService(name);
	}

}
